home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0052_PROGRAMMING SB AND FM.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-25  |  5KB  |  133 lines

  1. {
  2. As I promised, here is the other reply that I am sending you containing the
  3. information on Programming the SB via CT-VOICE.DRV.
  4.  
  5. Before I begin, This message may be a little long, so if for any reason, you
  6. loose the end of it or sumthin', let me know, and I'll repost it split up
  7. into sections, but right now I'll just make one long message.
  8.  
  9. O.K. Here we go...
  10. The information supplied will concern playback and recording of digital
  11. samples on the SB's digital channel(s) using the driver supplied by
  12. Creative Labs, CT-VOICE.DRV.
  13.  
  14. There should be a lot of information available on BBS's if you look for it
  15. and want to follow up anything, but for the meaan time, this information
  16. is taken from a book called "The Sound Blaster Book" by Axel Stolz,
  17. published by Abacus ISBN 1-55755-164-2.
  18.  
  19. Let me first correct myself about the comment that the driver is executed
  20. as an interrupt... Similar, but not quite... You don't actually make and
  21. interrupt call (i.e: INT n), but rather make the actual call to the address
  22. that the driver was loaded into (i.e: CALL n).
  23.  
  24. The first thing you need to do is load the driver into memory.  Note, the
  25. segment may be anywhere (you store the pointer as a reference), but the
  26. offset MUST be zero.  The loading is done as follows...
  27. 1.) Allocate memory and get pointer to the block.
  28. 2.) Load the driver from disk into the allocated space.
  29. Note: I am not going into much detail regarding error checking, but you
  30. should do checking on things such as allocation being ok and not NULL, and
  31. see whether the file exists on the disk, and whether or not it is a valid
  32. driver (this can be done by checking to see that the letters "CT" are
  33. contained in bytes 3 and 4).
  34.  
  35. The code is as follows (in Pascal):
  36. (Please forgive any minor discrepencies, as I am not a Pascal programmer,
  37.  but a C programmer, and I'm only trying to extract those sections that seem
  38.  inportant, so I may not know which functions are Pascal's and which are
  39.  user defined, but you should get the general idea. )
  40. }
  41. VAR
  42.    F : File;
  43.    PtrToDrv : Pointer;
  44.  
  45. BEGIN
  46.    Assign( F, 'CT-VOICE.DRV' );
  47.    Reset( F, 1 );
  48.    AllocateMem( PtrToDrv, FileSize(F) );
  49.    Blockread( F, PtrToDrv^, FileSize(F) );
  50.    Close( F );
  51. END;
  52. {
  53. NOTE: The varible PtrToDrv should be global, as you will be needing it to
  54. reference the memory at a later stage.
  55.  
  56. Now that you have the driver loaded, you can start to make function calls
  57. to it.  This is done by setting the register BX to the number of the
  58. function that you want to execute, and various other memory registers to
  59. the parameters, and then calling the address stored in the "PtrToDrv"
  60. varible.  Return values are usually stored in the register AX.
  61.  
  62. EXAMPLE: Function 6: Play a sample:
  63. -------- Input registers:  BX = Function number
  64.                            ES:DI = Pointer to sample
  65.          Return registers: None.
  66. }
  67. PROCEDURE PlaySample( BufferAddr : Pointer );
  68. VAR
  69.    VSeg, VOfs : WORD;
  70. BEGIN
  71.    VSeg := Seg( BufferAddr^ );
  72.    VOfs := Ofs( BufferAddr^ );
  73.    ASM
  74.       MOV   BX, 6
  75.       MOV   ES, VSeg
  76.       MOV   Di, VOfs
  77.       CALL  PtrToDrv
  78.    END;
  79. END;
  80.  
  81. {
  82. The following are a list of all the function available from the CT-VOICE.DRV
  83. driver.  Note, you will call them by setting BX = function number, setting
  84. the other registers, and then executing "CALL PtrToDrv":
  85.  
  86. ----------------------------------------------------------------------------
  87. #: Description:                  Parameters:
  88. -- -------------------------     -------------------------------------------
  89. 0  Determain driver version      AH=Main number (on return)
  90.                                  AL=Sub number (on return)
  91.  
  92. 1  Set port address              AX=Port address
  93.  
  94. 2  Set interrupt                 AX=Interrupt number
  95.  
  96. 3  Initialize driver             AX=0 Successfull (on return)
  97.                                  AX=1 SB not found (on return)
  98.                                  AX=2 Port address error (on return)
  99.                                  AX=3 Interrupt error (on return)
  100.  
  101. 4  Loudspeaker on/off            AL=0 off
  102.                                  AL=1 on
  103.  
  104. 5  Set "StatusWord" address      ES:DI=Status address
  105.                                  (The WORD varible at this address will store
  106.                                   the status of the playback so that you can
  107.                                   monitor the playback of the sample.)
  108.  
  109. 6  Sample playback               ES:DI=Sample address
  110.  
  111. 7  Record sample                 AX=Sampling rate
  112.                                  DX:CX=Length
  113.                                  ES:DI=Sample address
  114.  
  115. 8  Abort sample                  none
  116.  
  117. 9  De-Install driver             none
  118.                               
  119. 10 Pause Sample                  AX=0 Successfull (on return)
  120.                                  AX=1 Not successfull (on return)
  121.  
  122. 11 Continue sample               AX=0 Successfull (on return)
  123.                                  AX=1 Not successfull (on return)
  124.  
  125. 12 Interrupt loop                AX=0 At end of loop
  126.                                  AX=1 Immediately
  127.                                  AX=0 Successfull (on return)
  128.                                  AX=1 No loop being executed
  129.  
  130. 13 User defined driver function  DX:AX=Function address
  131.                                  ES:BX=Address of the current data block
  132. }
  133.